<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import exchangeRate from '@/api/finance/exchangeRate'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()

const options = reactive({
  id: 'exchange_rate',
  pageLayout: 'fixed',
  rowSelection: {
    showCheckedAll: true
  },
  beforeRequest: (params) => {
    params.orderBy = 'validate_time'
    params.orderType = 'desc'
  },
  pk: 'id',
  operationColumn: true,
  operationColumnWidth: 160,
  formOption: {
    viewType: 'drawer',
    width: "80%"
  },
  tabs:{
    dataIndex: "currency_code"
  },
  api: exchangeRate.getList,
  recycleApi: exchangeRate.getRecycleList,
  add: {
    show: true,
    api: exchangeRate.save,
    auth: ['finance:exchangeRate:save']
  },
  edit: {
    show: true,
    api: exchangeRate.update,
    auth: ['finance:exchangeRate:update']
  },
  delete: {
    show: true,
    api: exchangeRate.deletes,
    auth: ['finance:exchangeRate:delete'],
    realApi: exchangeRate.realDeletes,
    realAuth: ['finance:exchangeRate:realDeletes']
  },
  recovery: {
    show: true,
    api: exchangeRate.recoverys,
    auth: ['finance:exchangeRate:recovery']
  }
})

const columns = reactive([
  {
    title: "主键",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入主键"
    }
  },
  {
    title: "货币",
    dataIndex: "currency_code",
    formType: "select",
    dict: {
      name: 'currencyType',
      props: {
        label: "title",
        value: "key"
      },
      translation: true,
    },
    search: true,
    commonRules: {
      required: true,
      message: "请选择货币"
    }
  },
  {
    title: "汇率",
    dataIndex: "exchange_rate",
    formType: "input",
    commonRules: {
      required: true,
      message: "请填写汇率"
    }
  },
  {
    title: "生效时间",
    dataIndex: "validate_time",
    formType: "date",
    showTime: true,
    commonRules: {
      required: true,
      message: "请选择生效时间"
    }
  },
  {
    title: "创建者",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "更新者",
    dataIndex: "updated_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    showTime: true
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "备注",
    dataIndex: "remark",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  }
])
</script>
<script> export default { name: 'finance:exchangeRate' } </script>